/*
 * @Author: Otway
 * @Date: 2019-01-09 11:16:08
 * @LastEditors: Otway
 * @LastEditTime: 2019-08-30 18:50:09
 * @copyright: h-visions
 */
import React, { PureComponent } from "react";
import {
  Row,
  Col,
  Form,
  Input,
  Select,
  // Checkbox,
} from "antd";
// import TextArea from 'antd/lib/input/TextArea';
const FormItem = Form.Item;
// const { Option } = Select
// const CheckboxGroup = Checkbox.Group;
const formItemLayout = {
  // 抽屉里面Form。二列的布局比例
  labelCol: {
    span: 6,
  },
  wrapperCol: {
    span: 18,
  },
};
const { Option } = Select;
class AddFrom extends PureComponent {
  render() {
    const {
      formData,
      one,
      form: { getFieldDecorator },
    } = this.props;

    return (
      <Form>
        <Row>
          <Col span={24}>
            <FormItem {...formItemLayout} label={"工序编码:"}>
              {getFieldDecorator("procedureCode", {
                initialValue: one ? formData.procedureCode : null,
                rules: [
                  {
                    required: true,
                    message: "工序编码为空",
                  },
                ],
                getValueFromEvent: (event) => {
                  return event.target.value.replace(/\s+/g, "");
                },
              })(
                <Input placeholder="输入工序编码" allowClear maxLength={20} />
              )}
            </FormItem>
          </Col>
          <Col span={24}>
            <FormItem {...formItemLayout} label={"工序名称:"}>
              {getFieldDecorator("procedureName", {
                initialValue: one ? formData.procedureName : null,
                rules: [
                  {
                    required: true,
                    message: "工序名称为空",
                  },
                ],
                getValueFromEvent: (event) => {
                  return event.target.value.replace(/\s+/g, "");
                },
              })(
                <Input placeholder="输入工序名称" allowClear maxLength={20} />
              )}
            </FormItem>
          </Col>

          <Col span={24}>
            <FormItem {...formItemLayout} label={"工序类型:"}>
              {getFieldDecorator("procedureType", {
                initialValue: one ? formData.procedureType : "0",
                rules: [
                  {
                    required: true,
                    message: "请选择工序类型",
                  },
                ],
                getValueFromEvent: (val) => {
                  return val;
                },
              })(
                <Select placeholder="请选择">
                  <Option value="0">生产工序</Option>
                  <Option value="1">试机工序</Option>
                </Select>
              )}
            </FormItem>
          </Col>

          <Col span={24}>
            <FormItem {...formItemLayout} label={"备注:"}>
              {getFieldDecorator("remark", {
                initialValue: one ? formData.remark : "",
                rules: [
                  {
                    required: false,
                    message: "备注为空",
                  },
                ],
                getValueFromEvent: (event) => {
                  return event.target.value.replace(/\s+/g, "");
                },
              })(<Input placeholder="输入备注" allowClear maxLength={20} />)}
            </FormItem>
          </Col>
          {/* <Col span={24}>
                        <FormItem {...formItemLayout} label={'关联班组:'}>
                            {getFieldDecorator('teamCode', {
                                initialValue: one ? formData.teamCode : '',
                                rules: [
                                    {
                                        required: false,
                                        message: '关联班组为空'
                                    }
                                ]
                            })(<Input placeholder='输入关联班组' allowClear />)}
                        </FormItem>
                    </Col> */}
        </Row>
      </Form>
    );
  }
}

export default Form.create()(AddFrom);
